<?php

/**
 * Users Model
 *
 * Interacts with the users table in the database.
 *
 * @author David Beard
 * @version 1.0
 * @link https://code.google.com/p/lis3468final/
 */
class Users_model extends Model {

		/**
		 * Name of Function: Constructor
		 *
		 * Detailed Description: This is my constructor
		 * that automatically loads when this class is instantiated
		 *
		 * @author David
		 */
    function Users_model()
    {
        parent::Model();

        $this->load->database();
    }


		/**
		 * Add User
		 *
		 * Adds a user to the database.
		 *
		 * @return boolean
		 */
		function add_user()
		{
			//Load encryption
			//$this->load->library('encrypt');

			//Get the values
			$data = array();
			$data['username'] = $this->input->post('username');
			$data['email'] = $this->input->post('email');
			$data['password'] = $this->input->post('password'); //$this->encrypt->sha1($password);
			

			//Try it...
			$result = $this->db->insert('User', $data);
			return $result;
		}


            function validate()
            {
		$this->db->where('username', $this->input->post('username'));
		$this->db->where('password', ($this->input->post('password')));
		$query = $this->db->get('User');

		if($query->num_rows > 1)
                {
                        return FALSE;
                }
                    
                elseif($query->num_rows == 1)
                {
                        return TRUE;
                }


            }
}
/* EOF */